﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CodeTalk
{
    public class GUIHandler
    {
        public delegate void RefreshFunc();

        public RefreshFunc RefreshSymbolView { get; private set; }

        private TextBox feedbackTextBox;
        private ListBox alternativesListBox;
        private ProgressBar audioProgressBar;

        public GUIHandler(TextBox feedbackTextBox, ListBox alternativesListBox, ProgressBar audioProgressBar, RefreshFunc RefreshSymbolView)
        {
            this.feedbackTextBox = feedbackTextBox;
            this.alternativesListBox = alternativesListBox;
            this.audioProgressBar = audioProgressBar;
            this.RefreshSymbolView = RefreshSymbolView;
        }

        public void SetPrimaryFeedback(string text)
        {
            feedbackTextBox.Text = text;
            //alternativesListBox.Items.Clear();
        }

        public void SetErrorFeedback(string text)
        {
            SetPrimaryFeedback("Error: " + text);
        }

        public void SetAlternativesFeedback(string[] alternatives)
        {
            alternativesListBox.Items.Clear();
            for (int i = 1; i <= alternatives.Length; i++)
                alternativesListBox.Items.Add(i.ToString() + ": " + alternatives[i-1]);
        }

        public void SetAudioLevel(int level)
        {
            audioProgressBar.Value = level;
        }
    }
}
